<template>
  <div class="workWait">
    <Table border :columns="columns" :loading="loading" :data="tableData"></Table>
     <Page show-total :total="total" show-elevator :page-size='pageSize' @on-change='changePage'  style="margin:20px auto;text-align:center"/>
  </div>
</template>

<script>
import {getTableData} from '@/api/workWait'
export default {
  data () {
    return {
      loading:true,
      total:0,
      pageNo: 1,
      pageSize: 10,
      columns: [
        {
          type: 'index',
          width: 60,
          title: '序号',
          align: 'center'
        },
        {
          title: '待办类型',
          key: 'type',
          align: 'center',
          render: (h, params) => {
            let typeName=''
            if(params.row.type==1){
              typeName="报警确认"
            } else if(params.row.type==2){
              typeName="问题跟踪"
            } else if(params.row.type==3){
              typeName="试验计划"
            } else if(params.row.type==4){
              typeName="维修计划"
            } else if(params.row.type==5){
              typeName="机组状态待办"
            }
            return h('div', typeName)
          }
        },
        {
          title: '概述',
          key: 'overview'
        },
        {
          title: '时间',
          key: 'time'
        },
        {
          title: '操作',
          key: 'action',
          width: 100,
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  on: {
                    click: () => {
                      this.goUrl(params.row.type)
                      console.log(params)
                    }
                  }
                },
                '查看详情'
              )
            ])
          }
        }
      ],
      tableData: [
        {
          type: '机组报警',
          desc: '机组编号+报警测点+报警类型',
          time: '2016-10-03 12:23:32'
        },
        {
          type: '问题跟踪',
          desc: '功能位置+问题描述',
          time: '2016-10-03 12:23:32'
        },
        {
          type: '试验计划',
          desc: '机组编号+工作内容',
          time: '2016-10-03 12:23:32'
        },
        {
          type: '维修计划',
          desc: '机组编号+试验编号',
          time: '2016-10-03 12:23:32'
        },
        {
          type: '机组状态待办',
          desc: '机组编号+开/停机',
          time: '2016-10-03 12:23:32'
        }
      ],
    }
  },
  methods: {
    goUrl(type){
      if(type==1){
        this.$router.push({ path: "/state/stateMonitor" });
      }else if(type==2){
        this.$router.push({ path: "/problem/tefectTracking" });
      }else if(type==3){
        this.$router.push({ path: "/test/testPlan" });
      }else if(type==4){
        this.$router.push({ path: "/repair/repairPlan" });
      }else if(type==5){
        this.$router.push({ path: "/runManage/stateWait" });
      }
    },
    changePage (pageNo) {
      this.pageNo = pageNo
      this.getDataList()
    },
    getDataList () {
      getTableData({pageNo:this.pageNo,pageSize:this.pageSize,adminId:localStorage.getItem('recordUserId')}).then(res => {
        if (res.code == 0) {
          this.total = res.data.total
          this.tableData = res.data.list
          this.loading=false
        }
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
      })
    }
  },
  mounted () {
    this.getDataList()
  }
}
</script>

<style lang="less">
.workWait {
  background: #fff;
  height: 100%;
  padding: 15px;
  font-size: 14px;
}
</style>
